{% extends 'myadmin/base.html' %}

{% block main_body %}


<div style="height:60px">

</div>


  <section class="content">

      <div class="container-fluid">
        <div class="row">
          <div class="col-12">

    <div class="card">
              <div class="card-header">
                <h3 class="card-title"><a href="{% url 'myadmin_index' %}">首页</a> >> 用户信息管理</h3>
              </div>
              <div style="height:50px">
                <div style="width:120px;float:right;padding:10px;">
                   <button type="button" class="btn btn-block btn-primary" onclick="search()">浏览</button>
                </div>
               <div style="width:120px;float:right;padding:10px;">
                   <button type="button" class="btn btn-block btn-primary" onclick="add()">添加</button>
                </div>
                </div>
              <!-- /.card-header -->
              <div class="card-body">
                <table id="example2" class="table table-bordered table-hover">
                  <thead>
                  <tr>
                    <th>序号</th>
                    <th>用户姓名</th>
                    <th>用户昵称</th>
                      <th>用户年龄</th>
                    <th>用户状态</th>
                    <th>操作</th>
                  </tr>
                  </thead>
                  <tbody>
                  {% for user in userlist %}
                  <tr>
                    <td>{{ user.id }}</td>
                      <input type="hidden" id="userid" value="{{ user.id }}" />
                    <td>{{ user.username }}</td>
                    <td>{{ user.nickname }}</td>
                    <td> {{ user.age }}</td>
                    <td>
                        {% if user.status == 1 %}
                          有效
                        {% endif %}
                    </td>
                    <td><a href="{% url 'myadmin_user_edit' user.id %}?index=5" />编辑</a>  |  <a onclick="deluser()" style="cursor:pointer;" >删除</a> </td>
                  </tr>
                  {% endfor %}

                  </tfoot>
                </table>
              </div>
              <!-- /.card-body -->
            </div>
          </div>
        </div>
      </div>
  </section>


<script>
    function search() {
         window.location.href = "/myadmin/user/index";
    }
    function add() {
         window.location.href = "/myadmin/user/add?index=5";
    }
    function deluser(){
        if(confirm('确实要删除此用户吗?')){
          uid = document.getElementById('userid').value;
          //alert(uid);
          window.location.href = "/myadmin/user/delete/"+uid;
        }
    }
 </script>



{% endblock %}